# -*- coding: utf-8 -*-
from model.studio import Studio
from model.user import User
from werkzeug.exceptions import NotFound


def get_user_or_studio_from_id(id):
    try:
        user = User.get({
            User.Field._id: id
        }, [
            User.Field.name,
            User.Field.avatarUrl
        ])
        user.data['uType'] = 1
        return user.data
    except NotFound:
        try:
            studio = Studio.get({
                Studio.Field._id: id
            }, [
                Studio.Field.name,
                Studio.Field.avatarUrl
            ])
            studio.data['uType'] = 2
            return studio.data
        except:
            return {'_id': '', 'name': '', 'avatarUrl': '', 'uType': -1}
